package com.kk.permission.huawei.bnd_al00;

import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build.VERSION;

import com.kk.permission.GuideConst;
import com.kk.permission.handler.ConfigHandler;
import com.kk.permission.huawei.HuaweiPermissionAccessbilityHandlerBase;
import com.kk.permission.huawei.HuaweiPermissionStrategyBase;
import com.kk.permission.utils.OSUtil;
import com.kk.permission.utils.Permission;
import com.kk.permission.utils.callershow.CallerShowUtils;

import java.util.ArrayList;

public class HuaweiBNDAL00PermissionGuideStrategy extends HuaweiPermissionStrategyBase {
    private static final String TAG = "HuaweiPermissionGuide";

    public HuaweiBNDAL00PermissionGuideStrategy(Context context) {
        super(context);
    }

    protected void actionReadCalllog() {
        super.actionReadCalllog();
        actionTrustApplicationPermission(true);
    }

    protected void actionReadContact() {
        super.actionReadContact();
        actionTrustApplicationPermission(true);
    }

    protected void actionTrustApplicationPermission(boolean z) {
        super.actionTrustApplicationPermission(z);
        try {
            Intent intent = new Intent();
            intent.setClassName("com.huawei.systemmanager", GuideConst.HUAWEI_APP_PERMISSION_ACTIVITY_NAME);
            z = startIntentActivities(intent, GuideConst.TRUST_APPLICATION_PERMISSION, this.mAutoGuide);

        } catch (Throwable e) {
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:6:0x0059 A:{RETURN, Splitter: B:1:0x0003, ExcHandler: android.content.ActivityNotFoundException (unused android.content.ActivityNotFoundException)} */
    /* JADX WARNING: Removed duplicated region for block: B:6:0x0059 A:{RETURN, Splitter: B:1:0x0003, ExcHandler: android.content.ActivityNotFoundException (unused android.content.ActivityNotFoundException)} */
    /* JADX WARNING: Missing block: B:6:0x0059, code:
            return;
     */
    protected void actionAutoBootPermission() {
        /*
        r4 = this;
        super.actionAutoBootPermission();
        r0 = new android.content.Intent;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r0.<init>();	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1 = "com.huawei.systemmanager";
        r2 = "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity";
        r0.setClassName(r1, r2);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1 = "autoboot_permission";
        r2 = r4.mAutoGuide;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r0 = r4.startIntentActivities(r0, r1, r2);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1 = r4.mAutoGuide;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        if (r1 != 0) goto L_0x0059;
    L_0x001b:
        if (r0 == 0) goto L_0x0059;
    L_0x001d:
        r0 = new android.content.Intent;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1 = r4.mContext;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r2 = com.cootek.permission.OuterPermissionActivity.class;
        r0.<init>(r1, r2);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1 = "viewstub_id";
        r2 = com.cootek.permission.R.layout.general_permission_guide_mask;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r0.putExtra(r1, r2);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1 = "guidepic_id";
        r2 = com.cootek.permission.views.WrapViewGenerator.getInstance();	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r3 = com.cootek.permission.R.drawable.huawei_permission_autoreboot_next_y85;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r2 = r2.getViewByResId(r3);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r0.putExtra(r1, r2);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1 = "guide_hintone";
        r2 = com.cootek.permission.R.string.miui_permission_guide_template_one;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r2 = com.cootek.permission.utils.StringUtils.getFullStringWithAppName(r2);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r0.putExtra(r1, r2);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1 = "guide_hinttwo";
        r2 = r4.mContext;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r3 = com.cootek.permission.R.string.permission_autoboot_vivo_4_0;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r2 = r2.getString(r3);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r0.putExtra(r1, r2);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1 = r4.mContext;	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
        r1.startActivity(r0);	 Catch:{ ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059, ActivityNotFoundException -> 0x0059 }
    L_0x0059:
        return;
        */
        //throw new UnsupportedOperationException("Method not decompiled: com.cootek.permission.huawei.bnd_al00.HuaweiBNDAL00PermissionGuideStrategy.actionAutoBootPermission():void");
    }

    protected void actionToastPermission() {
        super.actionToastPermission();
        try {
            Intent intent = new Intent();
            intent.setClassName("com.huawei.systemmanager", GuideConst.HUAWEI_TOAST_PERMISSION_ACTIVITY_NAME_V2);
            boolean startIntentActivities = startIntentActivities(intent, GuideConst.TOAST_PERMISSION, this.mAutoGuide);

        } catch (ActivityNotFoundException unused) {
        } catch (Throwable e) {
        }
    }

    protected void actionBackgroundPermisssion() {
        super.actionBackgroundPermisssion();
        try {
            Intent intent = new Intent();
            intent.setClassName("com.huawei.systemmanager", GuideConst.HUAWEI_BACKGROUND_PROTECT_PERMISSION_ACTIVITY_NAME);
            boolean startIntentActivities = startIntentActivities(intent, GuideConst.BACKGROUND_PROTECT_PERMISSION, this.mAutoGuide);

        } catch (Throwable e) {
        }
    }

    protected void actionWhiteListPermisssion() {
        super.actionWhiteListPermisssion();
//        try {
//            Intent intent = new Intent();
//            intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.mainscreen.MainScreenActivity");
//            startIntentActivities(intent, "white_list", this.mAutoGuide);
//        } catch (Throwable e) {
//            TLog.printStackTrace(e);
//        }
    }

    protected void actionPermissionDeny(int i) {
        if (3 == i || 1 == i || 2 == i) {
            actionTrustApplicationPermission(true);
            return;
        }
        throw new IllegalArgumentException();
    }

    protected void actionCallogOrContactPermission() {
        super.actionCallogOrContactPermission();
        actionTrustApplicationPermission(true);
    }

    protected void actionDozePermission() {
        super.actionDozePermission();
        try {
            startIntentActivities(new Intent("android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS"), GuideConst.DOZE_PERMISSION, this.mAutoGuide);
        } catch (Throwable e) {
        }
    }

    public ArrayList<String> getPermissionList() {
        ArrayList<String> arrayList = new ArrayList();
        for (Permission permission : ConfigHandler.getInstance().getPermissionList()) {
            switch (permission) {
                case TOAST:
                    arrayList.add(GuideConst.TOAST_PERMISSION);
                    break;
                case CALL_RINGTONE:
//                    if(!PermissionListUtil.isSupportModifyWriteSettingPermission())
                        arrayList.add(GuideConst.CALL_RINGTONE_PERMISSION);
                    break;
                case DIAL_NOTI:
//                    if(!PermissionListUtil.notificationListenerEnable())
                        arrayList.add(GuideConst.DIAL_NOTI_PERMISSION);
                    break;
                case AUTO_BOOT:
                    arrayList.add(GuideConst.AUTOBOOT_PERMISSION);
                    break;
                case SHORTCUT:
                    arrayList.add(GuideConst.INSTALL_SHORT_CUT);
                    break;
                case BACKGROUND_PROTECT:
                    arrayList.add(GuideConst.BACKGROUND_PROTECT_PERMISSION);
                    break;
                case TRUST_APP:
                    arrayList.add(GuideConst.TRUST_APPLICATION_PERMISSION);
                    break;
                case SYSTEM_DIALING:
                    if (VERSION.SDK_INT < 23) {
                        break;
                    }
                    arrayList.add(GuideConst.SYSTEM_DIALING_PERMISSION);
                    break;
                default:
                    break;
            }
        }
        return arrayList;
    }

    protected void actionDialNotiPermission() {
        super.actionDialNotiPermission();
        try {
            boolean startIntentActivities = startIntentActivities(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"), GuideConst.DIAL_NOTI_PERMISSION, this.mAutoGuide);

        } catch (ActivityNotFoundException e) {

        }
    }

    public HuaweiPermissionAccessbilityHandlerBase getHandlerBase() {
        return new HuaweiBNDAL00PermissionAccessbilityHandler(this.mContext);
    }

    @SuppressLint("WrongConstant")
    protected void actionCallRingtonePermission() {
        super.actionCallRingtonePermission();
        try {
            CallerShowUtils.jumpToSysMidifySettingActivity(this.mContext);
            Intent intent = null;
            if (OSUtil.isRedMiNote4Android6() || OSUtil.isRedMi4Android6() || OSUtil.isXiaoMi8SEAndroid8()) {
                Intent intent2 = new Intent();
                intent2.putExtra("extra_pkgname", this.mContext.getPackageName());
                intent2.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.PermissionsEditorActivity");
                startIntentActivities(null, GuideConst.CALL_RINGTONE_PERMISSION, this.mAutoGuide);
            } else {
                intent = new Intent("android.settings.action.MANAGE_WRITE_SETTINGS");
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("package:");
                stringBuilder.append(this.mContext.getPackageName());
                intent.setData(Uri.parse(stringBuilder.toString()));
            }
            if (CallerShowUtils.isNeedClearTashTag()) {
                intent.setFlags(268435456);
                intent.addFlags(32768);
            }
            boolean startIntentActivities = startIntentActivities(intent, GuideConst.CALL_RINGTONE_PERMISSION, this.mAutoGuide);

        } catch (Exception e) {
            String str = TAG;
            StringBuilder stringBuilder2 = new StringBuilder();
            stringBuilder2.append("actionCallRingtonePermission Exception:");
            stringBuilder2.append(e.toString());
        }
    }

    protected void actionInstallShortCut() {
        super.actionInstallShortCut();

    }

    protected void actionSystemDialingPermission() {
        super.actionSystemDialingPermission();
        try {
            Intent intent = new Intent();
            intent.setClassName("com.android.settings", GuideConst.HUAWEI_SYSTEM_DIALING_PERMISSION_ACTIVTIY_NAME_V6);
            startIntentActivities(intent, GuideConst.SYSTEM_DIALING_PERMISSION, this.mAutoGuide);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
